home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / utils / exception.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.7 KB  |  71 lines

  1. #ifndef    ExcIncluded
  2. #define ExcIncluded    1 /* %W% (serge) %G% */ /* $Header: /private/postgres/src/lib/H/utils/RCS/exception.h,v 1.2 1989/09/05 17:05:38 mao Version_2 $ */
  3.  
  4. #include <setjmp.h>
  5.  
  6. typedef char*        ExcMsg;
  7.  
  8. typedef struct {
  9.     ExcMsg    msg;
  10. } Exception;
  11.  
  12. typedef jmp_buf        ExcContext;
  13. typedef Exception*    ExcId;
  14. typedef long        ExcDetail;
  15. typedef char*        ExcData;
  16.  
  17. typedef struct ExcFrame {
  18.     struct ExcFrame    *link;
  19.     ExcContext    context;
  20.     ExcId        id;
  21.     ExcDetail    detail;
  22.     ExcData        data;
  23.     ExcMsg        msg;
  24. } ExcFrame;
  25.  
  26. extern    ExcFrame*    ExcCurFrameP;
  27.  
  28. #define    ExcBegin()                            \
  29.     {                                \
  30.         ExcFrame    exception;                \
  31.                                     \
  32.         exception.link = ExcCurFrameP;                 \
  33.         if (setjmp(exception.context) == 0) {            \
  34.             ExcCurFrameP = &exception;            \
  35.             {
  36. #define    ExcExcept()                            \
  37.             }                        \
  38.             ExcCurFrameP = exception.link;            \
  39.         } else {                        \
  40.             {
  41. #define    ExcEnd()                            \
  42.             }                        \
  43.         }                            \
  44.     }
  45.  
  46. #define raise(exception)    raise2((exception), 0)
  47. #define raise2(x, detail)    raise3((x), (detail), 0)
  48. #define raise3(x, t, data)    raise4((x), (t), (data), 0)
  49.  
  50. #define raise4(x, t, d, msg) \
  51.     ExcRaise(&(x), (ExcDetail)(t), (ExcData)(d), (ExcMsg)(msg))
  52.  
  53. #define    reraise() \
  54.     raise4(exception.id, exception.detail, exception.data, exception.msg)
  55.  
  56. typedef    void    ExcProc(/* Exception*, ExcDetail, ExcData, ExcMsg */);
  57.  
  58. extern    void    ExcRaise(/* Exception*, ExcDetail, ExcData, ExcMsg */);
  59.  
  60. extern    ExcProc    *ExcGetUnCaught();
  61. extern    ExcProc    *ExcSetUnCaught(/* ExcProc * */);
  62.  
  63. extern    void    ExcUnCaught(/* Exception*, ExcDetail, ExcData, ExcMsg */);
  64.  
  65. extern    void    ExcPrint(/* Exception*, ExcDetail, ExcData, ExcMsg */);
  66. extern    char*    ProgramName;
  67.  
  68. extern    void    ExcAbort(/* Exception*, ExcDetail, ExcData, ExcMsg */);
  69.  
  70. #endif    /* !defined(ExcIncluded) */
  71.